package com.twu.biblioteca.command;

import com.twu.biblioteca.db.BookStore;
import com.twu.biblioteca.model.User;
import com.twu.biblioteca.utilities.ConsoleReader;
import com.twu.biblioteca.utilities.MessagePrinter;

public class CheckoutBookCommand implements Command {
    private User currentUser;
    private MessagePrinter printer;
    BookStore bookStore;
    ConsoleReader reader;

    public CheckoutBookCommand(User currentUser, MessagePrinter printer, BookStore bookStore, ConsoleReader reader) {
        this.currentUser = currentUser;
        this.printer = printer;
        this.bookStore = bookStore;
        this.reader = reader;
    }

    @Override
    public void execute() {
        if(bookStore.checkout(reader.readIdFromConsole("Book"), currentUser))
            printer.printSuccessCheckoutMessage("Book");
        else
            printer.printErrorCheckoutMessage("Book");
    }
}
